package org.example.controller;

import org.example.service.UserService;
import org.example.vo.ResultVo;
import org.example.vo.UserDelReq;
import org.example.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/user-list")
    public ResultVo<List<UserVo>> listUsers() {
        List<UserVo> userVos = userService.userList();
        return new ResultVo<List<UserVo>>().success(userVos);
    }

    @PostMapping("/delete-users")
    public ResultVo<Void> deleteUsers(@RequestBody UserDelReq delReq) {
        userService.deleteUsers(delReq.getUserAccounts());
        return new ResultVo<Void>().voidSuccess();
    }

}
